using BCW.Friends;
using UnityEngine;

public class butScrollPlayers : MonoBehaviour
{
	public UILabel labelNomPlayers;

	public UILabel labelNamePlayers;

	public UILabel labelPointsPlayers;

	public UILabel labelLevelPlayers;

	public UISprite bg;

	public UISprite buttonFriend;

	private string spritePlus = "Buttons";

	private string spriteSended = "Check";

	private string spriteFriend = "iconMap_Zombie";

	public string idPlayer;

	[SerializeField]
	private GameObject addPlayer;

	[SerializeField]
	private GameObject addPlayerInactive;

	[SerializeField]
	private GameObject addedPlayer;

	[SerializeField]
	private GameObject friendPlayer;

	public int indentificator;

	private void OnClick()
	{
	}

	private void OnEnable()
	{
		FriendsUIGame.CantSendInvite += Active;
		if (!FriendsUIGame.instance.CanSendInvite())
		{
			Active();
		}
	}

	public void ClickButton()
	{
		FriendsUIGame.instance.ShowWarningMsg(this);
	}

	private void OnDisable()
	{
		FriendsUIGame.CantSendInvite -= Active;
	}

	private void OnDestroy()
	{
		FriendsUIGame.CantSendInvite -= Active;
	}

	public void CallBackFriend(ServerResponse response)
	{
		switch (response)
		{
		case ServerResponse.Successful:
			ChangeTexture(FriendsButton.Sended);
			FriendsUIGame.instance.listSendedIds.Add(idPlayer);
			break;
		case ServerResponse.ServerFail:
			FriendsUIGame.instance.curInvitePlayer++;
			if (FriendsUIGame.instance.CanSendInvite())
			{
				ChangeTexture(FriendsButton.Plus);
			}
			else
			{
				ChangeTexture(FriendsButton.InactiveFriend);
			}
			break;
		case ServerResponse.WrongFormat:
			ChangeTexture(FriendsButton.InactiveFriend);
			break;
		}
		FriendsUINotification.instance.AddInQueueWarninMsg(response);
	}

	public void ChangeTexture(FriendsButton friend)
	{
		switch (friend)
		{
		case FriendsButton.Friend:
			addPlayer.SetActive(false);
			addPlayerInactive.SetActive(false);
			addedPlayer.SetActive(false);
			friendPlayer.SetActive(true);
			break;
		case FriendsButton.Plus:
			addPlayer.SetActive(true);
			addPlayerInactive.SetActive(false);
			addedPlayer.SetActive(false);
			friendPlayer.SetActive(false);
			break;
		case FriendsButton.Sended:
			addPlayer.SetActive(false);
			addPlayerInactive.SetActive(false);
			addedPlayer.SetActive(true);
			friendPlayer.SetActive(false);
			break;
		case FriendsButton.InactiveFriend:
			addPlayer.SetActive(false);
			addPlayerInactive.SetActive(true);
			addedPlayer.SetActive(false);
			friendPlayer.SetActive(false);
			break;
		case FriendsButton.Me:
			addPlayer.SetActive(false);
			addPlayerInactive.SetActive(false);
			addedPlayer.SetActive(false);
			friendPlayer.SetActive(false);
			break;
		}
	}

	private void Active()
	{
		if (addPlayer.activeSelf)
		{
			ChangeTexture(FriendsButton.InactiveFriend);
		}
	}
}
